<%--
  Created by IntelliJ IDEA.
  User: zhangyc
  Date: 2017/11/10
  Time: 11:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    String user_accesss="{\"ac_name\":\"user_access\",\"biz_data\":{\"user_name\":\"信用猫\",\"user_mobile\":\"17000001234\"}}";
    String base_info_commit="{\"ac_name\":\"base_info_commit\",\"biz_data\": {\"user_id\": \"XYM_16781\",\"zhima_score\": 750,\"educations\": 3,\"marrital\": 3,\"province\": \"北京\",\"city\": \"北京市\",\"county\": \"朝阳区\",\"addr_detail\": \"北京 北京市 朝阳区 望京广顺南大街16号院1号楼23层\",\"company\": \"51信用卡\",\"company_province\": \"北京\",\"company_city\": \"北京市\",\"company_county\": \"朝阳区\",\"company_addr_detail\": \"北京 北京市 朝阳区 望京广顺南大街16号院1号楼23层\",\"emergency_contact_person_name\": \"阿黄\",\"emergency_contact_person_phone\": \"15877776666\",\"id_positive\": \"http://api.creditcat.cn/slkmgaseotjsalk999\",\"id_negative\": \"http://api.creditcat.cn/slkmgaseotjsalk999\",\"ocr_img\": \"[\\\"http:\\\\/\\\\/api.creditcat.cn\\\\/slkmgaseotjsalk999\\\",\\\"http:\\\\/\\\\/api.creditcat.cn\\\\/etdvklsds999ssss54\\\",\\\"http:\\\\/\\\\/api.creditcat.cn\\\\/slkmgaseotjsalk999\\\"]\"}}";
    String addressbook_commit="{\"ac_name\":\"addressbook_commit\",\"biz_data\": {\"user_id\": \"XYM_1234534\",\"phonelist\": \"[\\\"张三_13555550012\\\",\\\"李四_18011112222\\\",\\\"小王_15807775555\\\"]\"}}";
    String phone_commit="{\"ac_name\":\"phone_commit\",\"biz_data\":{\"user_id\":\"XYM_11234\",\"base\":{\"mobile\": \"15211031990\",\"type\": \"移动\",\"province\": \"湖南\",\"city\": \"长沙市\",\"open_time\": \"2015-12-31 11:03:51\",\"truename\": \"张婷\",\"id_card\": \"610526199901011921\",\"address\": \"陕西省蒲城县罕井镇长安街41号1号楼68号\",\"balance\":\"190.82\",\"certify\": \"实名认证\",\"create_time\": \"2016-03-07 16:41:15\"},\"call\": {\"2016-02\": [{\"calltime\": \"2016-02-10 13:20:54\",\"callphone\": \"15137661982\",\"thtypename\": \"语音电话\",\"calllong\": \"240\",\"calltype\": \"主叫\",\"landtype\": \"国内长途\",\"homearea\": \"北京\",\"otherarea\": \"\"}]},\"gprs\": {\"2016-02\": {\"total_flow\": \"483M\"}},\"bill\": {\"2016-01\": {\"total_fee\": \"51.40\",\"base_fee\": \"30.00\",\"gprs_fee\": \"\",\"call_fee\": \"\",\"sms_fee\": \"\"}},\"sms\": {\"2016-02\": [{\"smstime\": \"2015-09-02 20:09:32\",\"smsphone\": \"15061972931\",\"homearea\": \"0519\",\"smsfee\": \"0.00\",\"smstype\": \"发送\",\"businesstype\": \"短信\"}]}}}";
    String order_commit="{\"ac_name\":\"order_commit\",\"biz_data\": {\"user_id\": \"XYM_1234\"}}";
    String order_calculate="{\"ac_name\":\"order_calculate\",\"biz_data\":{\"user_id\": \"XYM_123\",\"amount\": 8000,\"peroid\": 12}}";
    String bank_card_commit="{\"ac_name\":\"bank_card_commit\",\"biz_data\": {\"user_id\": \"XYM_12323\",\"bank_code\": \"ICBC\",\"bank_card\": \"6228481698729890077\",\"mobile\": \"18518765656\"}}";
    String contract_index="{\"ac_name\":\"contract_index\",\"biz_data\":{\"user_id\":\"XYM_1232\",}}";
    String order_addorder="{\"ac_name\":\"order_addorder\",\"biz_data\": {\"user_id\": \"XYM_12324\",\"loan_amount\": 8000,\"loan_term\": 12}}";
    String order_orderstatus="{\"ac_name\":\"order_orderstatus\",\"biz_data\":{\"user_id\":\"XYM_1234\",\"order_id\":\"57973a76b74e753b95cb0423\"}}";
    String order_repaymentplan="{\"ac_name\":\"order_repaymentplan\",\"biz_data\":{\"user_id\":\"13cbfbf89eacfda90d20a7e82a0054fe\",\"order_id\":\"57973a76b74e753b95cb0423\"}}";
    String order_repayment="{\"ac_name\":\"order_repayment\",\"biz_data\":{\"user_id\":\"XYM_1234\",\"order_id\":\"57973a76b74e753b95cb0423\"}}";
%>
<html>
<head>
    <title>接口测试页</title>
</head>
<body>
<h1 align="center">欢迎使用接口测试</h1>
<div>
    <table align="center">
        <tr>
            <table id="requestTable" align="left">
                <tr>
                    <td align="left" width="80px">请求接口:</td>
                    <td align="left" style="width:90%">
                        <select id="interfaceSelect" name="interfaceSelect" onchange="changeInterface(this.value)">
                            <option value="0" selected="selected">----------------------------------------请选择----------------------------------------</option>
                            <option value="3">准入查询接口</option>
                            <option value="4">接收基本信息接口</option>
                            <option value="5">上传通讯录接口</option>
                            <option value="6">运营商数据接口</option>
                            <option value="7">授信接口</option>
                            <option value="9">试算接口</option>
                            <option value="10">绑卡接口</option>
                            <option value="11">合同查询接口</option>
                            <option value="12">下单(放款)接口</option>
                            <option value="13">查询订单状态接口</option>
                            <option value="14">查询还款计划接口</option>
                            <option value="15">主动还款接口</option>
                        </select>
                    </td>
                    <td align="left" >
                        <button type="button" value="请求" onclick="submit()">请求</button>
                    </td>
                </tr>
                <tr>
                    <td width="80px">
                    </td>
                    <td align="left" style="width:90%">
                        <textarea id="params" rows="10" style="word-wrap:break-word;word-break:break-all;width:90%;"></textarea>
                    </td>
                    <td>
                    </td>
                </tr>
            </table>
        </tr>
        <tr>
            <table id="responseTable" align="left">
                <tr>
                    <td width="80px">运行日志:</td>
                    <td align="left" style="width:90%">
                        <p id="log"  style="white-space:pre-wrap;word-wrap:break-word;word-break:break-all;"></p>
                    </td>
                    <td></td>
                </tr>
                <tr>
                    <td width="80px">返回结果:</td>
                    <td align="left" style="width:90%">
                        <p id="result"  style="word-wrap:break-word;word-break:break-all;"></p>
                    </td>
                    <td></td>
                </tr>
            </table>
        </tr>
    </table>
</div>
</body>
<script type="text/javascript"  src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js" ></script>
<script>
    function changeInterface(interfaceCode) {
        var params={};
        if(interfaceCode==3){
            params=<%=user_accesss%>;
        }else if(interfaceCode==4){
            params=<%=base_info_commit%>;
        }else if(interfaceCode==5){
            params=<%=addressbook_commit%>;
        }else if(interfaceCode==6){
            params=<%=phone_commit%>;
        }else if(interfaceCode==7){
            params=<%=order_commit%>;
        }else if(interfaceCode==9){
            params=<%=order_calculate%>;
        }else if(interfaceCode==10){
            params=<%=bank_card_commit%>;
        }else if(interfaceCode==11){
            params=<%=contract_index%>;
        }else if(interfaceCode==12){
            params=<%=order_addorder%>;
        }else if(interfaceCode==13){
            params=<%=order_orderstatus%>;
        }else if(interfaceCode==14){
            params=<%=order_repaymentplan%>;
        }else if(interfaceCode==15){
            params=<%=order_repayment%>;
        }else{
            params={msg:"参数错误"};
        }
        document.getElementById("params").innerHTML = JSON.stringify(params);
    }
    function submit() {
        var params=$("#params").val();
        var url="<%=basePath%>api-test/request";
        $.ajax({
            type:"POST",
            url: url,
            contentType: "application/json",
            data:params,
            dataType: "json",
            cache:false,
            success:function(data){
                document.getElementById("log").innerHTML = data.log;
                if(data.code==1){
                    document.getElementById("result").innerHTML = JSON.stringify(data.data);
                }else{
                    document.getElementById("result").innerHTML = data.msg;
                }

            }
        });
    }
</script>
</html>
